
import com.java.demo.controller.UserController;
import com.java.demo.controller.UserController2;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class App {


    public static void main(String[] args) {

        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        UserController2 userController2 = context.getBean("userController2",UserController2.class);
        userController2.sayHi();


//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        UserController controller = context.getBean("userController",UserController.class);
//        controller.sayHi();


//        //1.得到Spring对象
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//
//        //2.得到bean对象
//        StudentController studentController = context.getBean("studentController",StudentController.class);
//        //3.使用bean对象
//        studentController.sayHi();


//        //1.得到Spring对象
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        //2.得到bean对象
//        TeacherController teacherController = context.getBean("teacherController",TeacherController.class);
//        //3.使用bean对象
//        teacherController.sayHi();


        //service注解
//        //1.得到Spring对象
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        //2.得到bean对象
//        StudentController2 studentController2 = context.getBean("studentController2",StudentController2.class);
//        //3.使用bean对象
//        studentController2.sayHi();


        //repository注解
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        StudentController3 studentController3 = context.getBean("studentController3",StudentController3.class);
//        studentController3.sayHi();


        //component注解
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        StudentController4 studentController4 = context.getBean("studentController4",StudentController4.class);
//        studentController4.sayHi();







        //configuration注解
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        StudentController5 studentController5 = context.getBean("studentController5",StudentController5.class);
//        studentController5.sayHi();


        //bean
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        UserService userService = context.getBean("userService",UserService.class);
//        userService.sayHi();



        //controller.jing controller注解
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        StudentController6 studentController6 = context.getBean("studentController6",StudentController6.class);
//        studentController6.sayHi();

        //bean
//        ApplicationContext context  = new ClassPathXmlApplicationContext("spring-config.xml");
//        User user = context.getBean("getuserbyname",User.class);
//        System.out.println(user.getName());



    }
}

